const express=require('express')
const app=express()
const userRouter = require("./router/user");
const indexRouter = require("./router/index")
const productRouter = require("./router/products")
const staffRouter = require("./router/staff")

const cors = require('cors')
app.use(cors({
  origin:'*'
}))

app.listen(3000,()=>{console.log('I10研发成功')})

app.use(express.urlencoded({
  extended:false
}))

app.use('/user',userRouter)
app.use('/index',indexRouter)
app.use('/product',productRouter)
app.use('/staff',staffRouter)

app.use((err,req,res,next)=>{
  console.log(err)
  res.status(500).send({code:500,msg:'服务器端错误'})
})
